home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / ddmoduls.lha / dd_Modules / dd_hardware / dd_ciatimer_v40.e next >
Text File  |  1995-04-01  |  3KB  |  138 lines

  1. -> dd_ciatimer_v40.e - © 1994-1995 by Digital Disturbance. Freeware.
  2. -> Programmed by Leon Woestenberg (Email: leon@stack.urc.tue.nl)
  3.  
  4. -> FOLD OPTS
  5. OPT MODULE
  6. OPT PREPROCESS
  7. -> ENDFOLD
  8. -> FOLD MODULES
  9. MODULE 'exec/nodes'
  10. MODULE 'exec/libraries'
  11. MODULE 'exec/interrupts'
  12. MODULE 'hardware/cia'
  13. MODULE 'utility'
  14. MODULE 'utility/tagitem'
  15. MODULE 'lowlevel'
  16.  
  17. MODULE 'tools/debug'
  18. MODULE '*dd_debugon'
  19. -> ENDFOLD
  20. -> FOLD CONSTS
  21. EXPORT ENUM
  22.   DDA_CIA_Dummy=TAG_USER,
  23.   DDA_CIA_UseCIAA,
  24.   DDA_CIA_UseTimerA,
  25.   DDA_CIA_FallBack,
  26.   DDA_CIA_Interrupt,
  27.   DDA_CIA_MicroSecs
  28. -> ENDFOLD
  29. -> FOLD OBJECTS
  30. EXPORT OBJECT ciatimer PRIVATE
  31.   -> Add/RemTimerInt handle
  32.   inthandle
  33.   -> timervalue
  34.   counter
  35.   -> interrupt attached to a cia timer
  36.   interrupt:PTR TO is
  37. ENDOBJECT
  38. -> ENDFOLD
  39. -> FOLD DEFS
  40.  
  41. -> private global librarybases
  42. DEF lowlevelbase
  43. DEF utilitybase
  44.  
  45. -> ENDFOLD
  46.  
  47. -> FOLD new
  48. EXPORT PROC new(tags:PTR TO tagitem) OF ciatimer
  49.   DEF success=FALSE,temp
  50.  
  51.   -> utility library opened?
  52.   IF utilitybase:=OpenLibrary('utility.library',36)
  53.  
  54.     -> interrupt given?
  55.     IF temp:=GetTagData(DDA_CIA_Interrupt,NIL,tags)
  56.       self.interrupt:=temp
  57.  
  58.       -> lowlevel library opened?
  59.       IF lowlevelbase:=OpenLibrary('lowlevel.library',0)
  60.  
  61.         -> add timer interrupt
  62.         IF temp:=AddTimerInt(self.interrupt.code,self.interrupt.data)
  63.           self.inthandle:=temp
  64.  
  65.           -> set attributes
  66.           self.set(tags)
  67.  
  68.           success:=TRUE
  69.         ENDIF
  70.       ENDIF
  71.     ENDIF
  72.   ENDIF
  73. ENDPROC success
  74. -> ENDFOLD
  75. -> FOLD end
  76. EXPORT PROC end() OF ciatimer
  77.   -> valid handle?
  78.   KPUTSTR('end() called\n')
  79.  
  80.   -> interrupt added?
  81.   IF self.inthandle
  82.     KPUTSTR('removing icr vector\n')
  83.  
  84.     -> remove interrupt
  85.     RemTimerInt(self.inthandle)
  86.     self.inthandle:=NIL
  87.   ENDIF
  88.  
  89.   -> lowlevel library open?
  90.   IF lowlevelbase
  91.     KPUTSTR('closing lowlevel library\n')
  92.  
  93.     -> close lowlevel library
  94.     CloseLibrary(lowlevelbase)
  95.     lowlevelbase:=NIL
  96.   ENDIF
  97.  
  98.   -> utility library open?
  99.   IF utilitybase
  100.     KPUTSTR('closing utility library\n')
  101.  
  102.     -> close utility library
  103.     CloseLibrary(utilitybase)
  104.     utilitybase:=NIL
  105.   ENDIF
  106. ENDPROC
  107. -> ENDFOLD
  108. -> FOLD set
  109. EXPORT PROC set(tags) OF ciatimer
  110.   DEF microsecs
  111.   IF microsecs:=GetTagData(DDA_CIA_MicroSecs,0,tags)
  112.     self.counter:=microsecs
  113.  
  114.     KPUTFMT('timer counter now set to \d\n',[microsecs])
  115.   ENDIF
  116. ENDPROC
  117. -> ENDFOLD
  118. -> FOLD start
  119. EXPORT PROC start() OF ciatimer
  120.   KPUTSTR('start()\n')
  121.   IF self.inthandle
  122.     KPUTSTR('starting timer\n')
  123.     StartTimerInt(self.inthandle,self.counter,TRUE)
  124.   ENDIF
  125. ENDPROC
  126. -> ENDFOLD
  127. -> FOLD stop
  128. EXPORT PROC stop() OF ciatimer
  129.   KPUTSTR('stop()\n')
  130.   IF self.inthandle
  131.     KPUTSTR('stopping timer\n')
  132.     StopTimerInt(self.inthandle)
  133.   ENDIF
  134. ENDPROC
  135. -> ENDFOLD
  136.  
  137.  
  138.